package com.woniu.service.imp;/*
 *
 * @author   米雷
 * @Description
 * @Date:create in 21:22 2020-03-27
 *
 * */

import com.woniu.dao.MessMapper;
import com.woniu.pojo.Mess;
import com.woniu.service.MessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MessServiceImp implements MessService {
    @Autowired
    MessMapper messMapper;

    @Override
    public List<Mess> getRecMess(Long id)
    {
        return messMapper.getRecByUserId(id);
    }

    @Override
    public List<Mess> getSendMess(Long id)
    {
        return messMapper.getSendByUserID(id);
    }

    @Override
    public String addMess(Mess mess)
    {
        int i = messMapper.insert(mess);
        if (i!=0){
            return "发送成功";
        }else {
            return "发送失败";
        }
    }

    public String delRecMess(Long id)
    {
        int i = messMapper.delRec(id);
        if (i!=0){
            return "删除成功";
        }else {
            return "删除失败";
        }
    }



    public String delSendMess(Long id)
    {
        int i = messMapper.delSend(id);
        if (i!=0){
            return "删除成功";
        }else {
            return "删除失败";
        }
    }

    @Override
    public List<Mess> getBySearch(Long id, String mes)
    {
        return messMapper.getBySearch(id,mes);
    }
}
